package no.cicero.testframework.model.testcase;

import java.util.HashMap;
import java.util.Map;

public abstract class StepParametersBase {
    private StepParametersBase parent;
    protected StepParametersBase getParent() { return parent; }
    
    private String description;
    public String getDescription() {
        if(description == null && parent != null)
            return parent.getDescription();
        return description;
    }
    public void setDescription(String description) {this.description = description;}

    private String webservice;
    public String getWebservice() {
        if(webservice == null && parent != null)
            return parent.getWebservice();
        return webservice;
    }
    public void setWebservice(String webservice) {this.webservice = webservice;}

    private String method;
    public String getMethod() {
        if(method == null && parent != null)
            return parent.getMethod();
        return method;
    }
    public void setMethod(String method) {this.method = method;}

    private Double precision;
    public Double getPrecision() {
        if(precision == null && parent != null)
            return parent.getPrecision();
        return precision;
    }
    public void setPrecision(Double precision) {this.precision = precision;}

	private Map<String, String> parameters = new HashMap<String, String>();

	public Map<String, String> getParameters() {
		Map<String, String> ret = new HashMap<String, String>();
		if(parent != null)
			ret.putAll(parent.getParameters());
		ret.putAll(parameters);
		return ret;
	}
	
	public String getParameter(String name) {
		return parameters.get(name);
	}
	public void setParameter(String name, String value){
		parameters.put(name, value);
	}


    public StepParametersBase() {
    }

    public StepParametersBase(StepParametersBase parent){
        this.parent = parent;
    }

    public StepParametersBase(String description, String webservice, String method, Double precision) {
        this.description = description;
        this.webservice = webservice;
        this.method = method;
        this.precision = precision;
    }
}
